<?php slot('sub', $sub); ?>

<script src="http://maps.googleapis.com/maps/api/js?key=AIzaSyA4ORL54bd4TqneYqWekkc22xhZ1T3gH6A&sensor=false"></script>

<div class="center">
    <div id="center_conteiner" class="clearfix">
        <div class="center_sub_conteiner"> 

            <div class="center_block">
                <div class="header_center_block" value="<?php echo $hotel['id']; ?>" civic="<?php echo $civic; ?>">
                    <span><?php echo $hotel['name_en']; ?></span>
                    <div class="back_button"><a href="<?php echo url_for('ahotels'); ?>">Back</a></div>
                    <div class="edit_title_button"><a href="<?php echo url_for('edithotel', array('hotel_id' => $hotel['id'])); ?>">Edit</a></div>
                </div>

                <div class="hotel_image_column_container">
                    <div class="hotel_main_image">
                        <div class="main_images">
                            <?php
                            if ($hotel['photo']) {
                                $images = explode(';', $hotel['photo']);
                                for ($i = 0; $i < (count($images) - 1); $i++) {
                                    echo '<img class="image_hotel_' . $i . '"  src="' . $images[$i] . '" value="' . $i . '">';
                                }
                            } else {
                                echo '<img src="../images/empty.png">';
                            }
                            ?>
                        </div>
                    </div>


                    <div class="arrows_image_container">
                        <div class="arrows_left_image"><img src="/web/images/left-arrow.png"></div>
                        <div class="arrows_rigth_image"><img src="/web/images/right-arrow.png"></div>
                    </div>
                </div>

                <div class="hotel_description_column">
                    <div class="hotel_main_description_container">
                        <div class="hotel_description_name"><?php echo $hotel['name_en']; ?></div>
                        <div class="hotel_description_stars">
                            <?php
                            switch ($hotel['stars']) {
                                case 1:
                                    echo '<img src="/web/images/icoStar.png">';
                                    break;
                                case 2:
                                    echo '<img src="/web/images/icoStars2.png">';
                                    break;
                                case 3:
                                    echo '<img src="/web/images/icoStars3.png">';
                                    break;
                                case 4:
                                    echo '<img src="/web/images/icoStars4.png">';
                                    break;
                                case 5:
                                    echo '<img src="/web/images/icoStars5.png">';
                                    break;
                            }
                            ?>
                        </div>
                        <div class="hotel_description_des"><?php echo $hotel['description_en']; ?></div>
                    </div>

                    <div class="hotel_description_address_info">
                        <div class="hotel_description_address_info_header">Contact information</div>
                        <div class="hotel_description_address"><label>Address: </label><?php echo $hotel['address']; ?></div>
                        <div class="hotel_description_phones"><label>Phone: </label><?php echo $hotel['phone1'] . ' ' . $hotel['phone2']; ?></div>
                        <div class="hotel_description_fax"><label>Fax: </label><?php echo $hotel['fax']; ?></div>
                        <div class="hotel_description_email"><label>E-mail: </label><?php echo $hotel['email']; ?></div>
                        <div class="hotel_description_link"><label>Web site: </label><a href="<?php echo $hotel['web_site'] ?>"><?php echo $hotel['web_site'] ?></a></div>
                    </div>
                </div>

            </div>

            <div class="center_block">
                <div class="header_center_block">
                    <span>Map</span>
                    <div class="show_map">Show</div>
                </div>
                <div class="map_hotel_container" id="hotel_map"></div>
            </div>

            <div class="center_block">
                <div class="header_center_block">
                    <span>Rooms</span>
                    <div class="back_button"><a href="<?php echo url_for('addroom', array('hotel_id' => $hotel['id'])); ?>">Add Room</a></div>
                </div>

                <div class="users_title">
                    <div class="users_title_id">id</div>
                    <div class="users_title_title">name</div>
                    <div class="users_title_first_name">hotel name</div>
                    <div class="users_title_status">adult</div>
                    <div class="users_title_permissions">children</div>
                </div>

                <div class="room_hotel_description_container">
                    <?php
                    foreach ($hotel['Rooms'] as $r) {
                        echo '<div class="user_line">' .
                        '<div class="user_line_id">' . $r['id'] . '</div>' .
                        '<div class="user_line_title">' . $r['name'] . '</div>' .
                        '<div class="user_line_name">' . $hotel['name_en'] . '</div>' .
                        '<div class="user_line_status">' . $r['adult'] . '</div>' .
                        '<div class="user_line_permissions">' . $r['children'] . '</div>' .
                        '<div class="user_line_edit_button"><a href="' . url_for('editroom', array('room_id' => $r['id'])) . '">Edit</a></div>' .
                        '<div class="user_line_delete_button"><a href="' . url_for('deleteroom', array('room_id' => $r['id'], 'hotel_id' => $hotel['id'])) . '">' . 'Delete' . '</a></div>' .
                        '</div>';
                    }
                    ?>
                </div>

            </div>

        </div>
    </div>
</div>

<script>
    var latlong = {
        latitude: '<?php echo $hotel['latitude'] ?>',
        longitude: '<?php echo $hotel['longitude'] ?>'
    };
    var isMapShow = false;
    $(function() {
        $('.map_hotel_container').hide();

        $('.show_map').on('click', function() {
            if ($('.show_map').text() === 'Show') {
                $('.map_hotel_container').slideDown();
                $('.show_map').text('Hide');
                if (!isMapShow) {
                    isMapShow = true;
                    createGoogleMap();
                }
            } else {
                $('.map_hotel_container').slideUp();
                $('.show_map').text('Show');
            }
        });
    });

    function createGoogleMap() {
        var position;
        if (latlong.latitude && latlong.longitude) {
            position = [latlong.latitude, latlong.longitude];
        } else {
            position = [32.104813299999996, 35.20501780000001];
        }
        var location = new google.maps.LatLng(position[0], position[1]);

        var mapOptions = {
            center: location,
            zoom: 9,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        var map = new google.maps.Map(document.getElementById("hotel_map"), mapOptions);
    }
</script>